home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / clang / mnp_c.zip / MNPC.DOC < prev    next >
Text File  |  1990-05-16  |  17KB  |  483 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.      
  8.      
  9.      
  10.      
  11.      
  12.                          The Microcom MNP Library
  13.                           (Microsoft C Version)
  14.      
  15.      
  16.      
  17.                            PROGRAMMER'S MANUAL
  18.      
  19.      
  20.      
  21.      
  22.      
  23.      
  24.      
  25.      
  26.      
  27.      
  28.      
  29.      
  30.      
  31.      
  32.                                 Version 1.0
  33.      
  34.                              December 15, 1987
  35.      
  36.      
  37.      
  38.      
  39.      
  40.      
  41.      
  42.      
  43.      
  44.      
  45.      
  46.      
  47.      
  48.      
  49.      
  50.      
  51.      
  52.      
  53.      
  54.      
  55.      
  56.      
  57.      
  58.                               Microcom, Inc.
  59.                           1400 Providence Highway
  60.                             Norwood, MA 02062
  61.  
  62.  
  63.  
  64.  
  65.  
  66.      
  67.      
  68.      The Microcom MNP Library and MNP are trademarks of Microcom, Inc.
  69.      Microsoft and MS-DOS are trademarks of Microsoft Corporation.  
  70.      IBM is a registered trademark of International Business Machines.
  71.      
  72.      
  73.      This manual is not subject to copyright and may be freely copied.
  74.      
  75.      
  76.      
  77.      
  78.      
  79.      
  80.      
  81.      
  82.      
  83.      
  84.      
  85.      
  86.      
  87.      
  88.      
  89.      
  90.      
  91.      
  92.      
  93.      
  94.      
  95.      
  96.      
  97.      
  98.      
  99.      
  100.      
  101.      
  102.      
  103.      
  104.      
  105.      
  106.      
  107.      
  108.      
  109.      
  110.      Questions relating to the Microcom MNP Library should be directed to
  111.      Microcom at:
  112.      
  113.                               Microcom, Inc.
  114.                        15303 Ventura Blvd., Suite 900
  115.                           Sherman Oaks, CA 91403
  116.                   Voice: (818)986-4212  Fax: (818)986-4214
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.      
  124.      1. INTRODUCTION
  125.      
  126.           The Microcom MNP Library is a set of subroutines which implement the
  127.      stream mode of the link protocol in Microcom Networking Protocol (MNP).
  128.      This mode of the MNP link protocol is appropriate for interworking with MNP
  129.      error-correcting modems or with other software implementations which use
  130.      the Microcom MNP Library or other compatible software.
  131.      
  132.           This version of the library provides a set of C and assembly
  133.      language routines which are designed to be easily integrated into an
  134.      application program written in C and compiled using the Microsoft C
  135.      compiler (version 4.0).  Through the use of these routines, an
  136.      application is able to perform error-free data communications over a
  137.      physical-connection, such as one established on the public switched
  138.      telephone network.
  139.      
  140.           These MNP Library subroutines are especially for the IBM Personal
  141.      Computer family (and compatibles) under PCDOS (MS-DOS).  Hardware
  142.      facilities for asynchronous communications are required.
  143.  
  144.  
  145.  
  146.  
  147.  
  148.      2. LIBRARY MODULES
  149.      
  150.           The Microcom MNP LIbrary is supplied in one of two forms, object
  151.      library only and object library with source.  The source version is de-
  152.      scribed in more detail in a file ('readme.doc') supplied as part of the
  153.      source version distribution.
  154.      
  155.           In the case of the object library only form, the distribution diskette
  156.      contains one file, mnp.lib, which includes the various object modules
  157.      which make up the MNP Library.
  158.      
  159.           When building the executable form of a particular application, the
  160.      mnp.lib file should be specified if the application calls any MNP sub-
  161.      routine described in this document.  The manner in which library modules
  162.      are specified for inclusion varies according to the linkage editor
  163.      employed in building the application program run module.
  164.  
  165.  
  166.  
  167.  
  168.  
  169.      3. LINK MANAGEMENT
  170.      
  171.           In general, the MNP link follows the life of the normal physical-
  172.      connection.  Immediately after the physical-connection is made (e.g. after
  173.      a modem first reports carrier detected), the application must attempt the
  174.      establishment of the Link via the MNPCONNECT subroutine.  MNP-capable
  175.      modems which answer the incoming telephone call, for example, must receive
  176.      the Link establishment sequence within 4 seconds of physical-connection
  177.      establishment.  If a link is not attempted within this period, such modems
  178.      may fall back to a normal connection and it will not be possible to provide
  179.      a reliable connection on that particular call.
  180.      
  181.           Link termination, performed via the MNPDISCONNECT call, should
  182.      immediately precede termination of the physical-connection, i.e. right
  183.      before hanging up the telephone.  Note that the Link is active for the
  184.      entire duration of the physical-connection.
  185.      
  186.           During the data phase of the Link (i.e. after establishment but before
  187.      termination), the Link must be kept running by allowing the Link code to
  188.      execute periodically.  Any of the data phase calls, namely MNPSEND,
  189.      MNPRECEIVE, MNPSTATUS, and MNPBREAK, will accomplish this.  One of these
  190.      routines must be called every 250ms or so which means that the Link code
  191.      gets a chance to run about 4 times per second.  The absolute interval is
  192.      not critical and it may be possible to reduce the frequency as well and
  193.      still get reasonable performance.  Polling the Link code, however, must
  194.      occur with a predictable frequency otherwise the Link may be lost.  When
  195.      the Link is lost, an MNP error-correcting modem may clear the call.
  196.      
  197.           When a Link is in progress, all line I/O is performed via the
  198.      appropriate MNP call rather than by using other C mechanisms.  It 
  199.      may be the case, however, that the com port opened elsewhere in the
  200.      application, must remain open.
  201.      
  202.           Data sent and received on the Link will be "chunked" depending on the
  203.      number of bytes which happen to be sent in a single data message.  The
  204.      maximum amount in a single message is 64 bytes.  This "chunking" is not
  205.      noticeable to the sender but can be perceived by the data receiver.
  206.      Strings of data may be split over more than one data message and some
  207.      messages may have to be sent more than once when there is noise on the
  208.      connection.  Retransmission can be seen by the application as an
  209.      interruption, possibly in the middle of some data string.  The application
  210.      should be examined to see if there are any cases involving timing
  211.      dependencies which could be adversely effected by this kind of 
  212.      irregularity in the data flow.
  213.  
  214.  
  215.  
  216.  
  217.  
  218.      4. LINK INTERFACE SUBROUTINES
  219.      
  220.      4.1  Link Establishment - MNPCONNECT
  221.      
  222.           MNPCONNECT is used to establish a Link.  It is called after the
  223.      physical-connection has been established.  It can take up to 5 seconds
  224.      for an MNPCONNECT call to complete.
  225.      
  226.           MNPCONNECT has the following parameters:
  227.      
  228.                RATE - an integer which indicates the speed of the
  229.                       physical-connection, as follows:
  230.      
  231.                           1 = 110 bps
  232.                           2 = 300 bps
  233.                           4 = 1200 bps
  234.                           5 = 2400 bps
  235.      
  236.                       [Note: Other speeds are not supported in this
  237.                        version of the Microcom MNP Library.]
  238.      
  239.                FORMAT - an integer which indicates the data format,
  240.                         as follows:
  241.      
  242.                          0 = 8 data bits, no parity
  243.                          1 = 7 data bits, even parity
  244.                          2 = 7 data bits, odd parity
  245.                          3 = 7 data bits, mark parity
  246.                          4 = 7 data bits, space parity
  247.      
  248.                       [Note: In this Library version, once the Link
  249.                        is established, it is not possible to change
  250.                        format.]
  251.      
  252.                PORT -  an integer which indicates the communications
  253.                        port, as follows:
  254.      
  255.                          1 = COM1
  256.                          2 = COM2
  257.      
  258.                       [Note: This Library version does not support
  259.                        other comm ports.  Also, COM2 cannot be speci-
  260.                        fied if no COM1 is present in the system.]
  261.      
  262.                MODE - an integer which indicates the role in link
  263.                       establishment, as follows:
  264.      
  265.                          0 = link initiator (caller)
  266.                          1 = link accepter (answerer)
  267.      
  268.  
  269.  
  270.  
  271.            The function returns an integer value, as follows:
  272.  
  273.                RETCODE - an integer returned to the caller which
  274.                          indicates the result of the link
  275.                          establishment attempt, as follows:
  276.      
  277.                          0 = success (link established)
  278.      
  279.                          -64 - failure, no additional info
  280.                          -65 - failure, timeout (no remote response)
  281.                          -66 - failure, physical-connection lost
  282.                                (carrier lost)
  283.                          -70 - failure, incompatible MNP
  284.                          -72 - failure, remote protocol error
  285.      
  286.                       [Note: -70 and -72 should never occur.]
  287.      
  288.      
  289.           MNPCONNECT is called as follows:
  290.      
  291.               RETCODE = MNPCONNECT(RATE,FORMAT,PORT,MODE);
  292.  
  293.  
  294.  
  295.  
  296.  
  297.      4.2  Link Termination - MNPDISCONNECT
  298.      
  299.           MNPDISCONNECT has two functions, to send the appropriate protocol
  300.      message to the other side to indicate Link termination and to reset the PC
  301.      interrupt environment.  MNPDISCONNECT must always be called if MNPCONNECT
  302.      had been called previously.  This is so even for establishment failure or
  303.      for loss of the physical-connection (i.e. carrier lost).
  304.      
  305.           MNPDISCONNECT has no parameters and returns no value.  It is
  306.      called as follows:
  307.      
  308.                             MNPDISCONNECT();
  309.  
  310.  
  311.  
  312.  
  313.  
  314.      4.3  Send Data - MNPSEND
  315.      
  316.           MNPSEND is called to copy data to be sent on the Link from the
  317.      application into the MNP transmit buffer.
  318.      
  319.           MNPSEND has parameters as follows:
  320.      
  321.                SNDBUF - a pointer to the user char buffer from which
  322.                         transmit data is to be copied.
  323.      
  324.                BUFLEN - an integer which indicates the maximum
  325.                         number of data bytes which can be copied
  326.                         from the user buffer
  327.      
  328.            The function returns an integer value, as follows:
  329.  
  330.                RETCODE - an integer returned to the caller which
  331.                          indicates the number of bytes copied
  332.                          or a Link error condition, as follows:
  333.      
  334.                          positive int = number of bytes copied
  335.                                          0=no bytes copied
  336.      
  337.                          -64 = link terminated, retransmission limit
  338.                                exceeded
  339.                          -65 = link terminated, unable to send
  340.                          -66 = link terminated, carrier lost
  341.                          -67 = link terminated, remote disconnected
  342.      
  343.           MNPSEND is called as follows:
  344.      
  345.                   RETCODE = MNPSEND(&SNDBUF,BUFLEN)
  346.  
  347.  
  348.  
  349.  
  350.  
  351.      4.4  Receive Data - MNPRECEIVE
  352.      
  353.           MNPRECEIVE is called to copy data received on the Link into the
  354.      application.  MNPRECEIVE transfers all available data up to the size of the
  355.      application buffer.  MNPRECEIVE returns immediately if no data is
  356.      available.
  357.      
  358.           MNPRECEIVE has the following parameters:
  359.      
  360.                RCVBUF - a pointer to the user char buffer into which
  361.                         received data is to be copied. This buffer must
  362.                         be at least as long as the value of BUFLEN.
  363.      
  364.                BUFLEN - an integer which indicates the maximum
  365.                         number of data bytes which can be copied
  366.                         into the user buffer
  367.  
  368.           The function returns an integer value, as follows:
  369.     
  370.                RETCODE - an integer returned to the caller which
  371.                          indicates the number of bytes copied
  372.                          or a Link error condition, as follows:
  373.      
  374.                          positive int = number of bytes copied
  375.                                         0=no bytes available.
  376.      
  377.                          -64 = link terminated.  retransmission limit
  378.                                exceeded
  379.                          -65 = link terminated, unable to send
  380.                          -66 = link terminated,  carrier lost
  381.                          -67 = link terminated, remote disconnected
  382.      
  383.           MNPRECEIVE is called as follows:
  384.      
  385.                   RETCODE =  MNPRECEIVE(&RCVBUF,BUFLEN);
  386.  
  387.  
  388.  
  389.  
  390.  
  391.      4.5  Link Status - MNPSTATUS
  392.      
  393.           MNPSTATUS is called to return to the application the status of the
  394.      Link and to read parameters which indicate the availability of received
  395.      data or the ability to enqueue data for transmission.
  396.      
  397.           MNPSTATUS has a structure as its parameter, with members
  398.      as follows:
  399.      
  400.                PSTATUS - an integer which indicates the condition of
  401.                          the physical-connection, as follows:
  402.      
  403.                          0 = not connected (carrier not present)
  404.                          1 = connected (carrier present)
  405.      
  406.                LSTATUS - an integer which indicates the condition of
  407.                          Link, as follows:
  408.      
  409.                          0 = link not established (i.e. link
  410.                              terminated)
  411.                          1 = link established
  412.      
  413.                SCOUNT - an integer which indicates the number of
  414.                         bytes free in the Link send buffer.  This is
  415.                         the number of bytes which can be completely
  416.                         copied to the Link transmit code via an
  417.                         MNPSEND call.
  418.      
  419.                RCOUNT - an integer which indicates the number of
  420.                         received data bytes which are available to
  421.                         be copied into the application via MNPRECEIVE
  422.      
  423.                ALLSENT - an integer which indicates whether or not
  424.                          all data passed to the Link code has been
  425.                          successfully sent and acknowledged, as
  426.                          follows:
  427.      
  428.                          0 = all data not sent
  429.                          1 = all data sent
  430.      
  431.      
  432.           MNPSTATUS is called as follows:
  433.      
  434.                       MNPSTATUS(&STATUS_BLOCK);
  435.  
  436.  
  437.  
  438.  
  439.  
  440.      4.6  Send Signal - MNPBREAK
  441.      
  442.           MNPBREAK is called to send a signal to the remote DTE.  When the
  443.      remote side is an MNP error-correcting modem, an MNPBREAK call causes the
  444.      remote modem to send a break signal (continuous spacing) to its attached
  445.      DTE.
  446.      
  447.           MNPBREAK employs the MNP Link Protocol's reliable attention
  448.      mechanism in 'destructive mode'.  That is, when MNPBREAK is called, the
  449.      Link is reset and any data pending transmission on the link is discarded as
  450.      is any received data which has not been read via the MNPRECEIVE subroutine.
  451.      Data may also be discarded at the remote side of the Link.
  452.      
  453.           MNPBREAK has no parameters but returns an integer value,
  454.      as follows:
  455.      
  456.                RETCODE - an integer returned to the caller which
  457.                          indicates the result of the MNPBREAK call
  458.                          or a Link error condition, as follows:
  459.      
  460.                          0 = break initiated
  461.      
  462.                          -64 = link terminated, retransmission limit
  463.                                exceeded
  464.                          -65 = link terminated, unable to send
  465.                          -66 = link terminated, carrier lost
  466.                          -67 = link terminated, remote disconnected
  467.                          -75 = break not supported (remote did not
  468.                                negotiate attention support for this
  469.                                Link)
  470.                          -76 = previous break still in progress
  471.      
  472.      
  473.           MNPBREAK is called as follows:
  474.      
  475.                           RETCODE = MNPBREAK();
  476.      
  477.      
  478.      
  479.           [Note that the MNP Library does not support application
  480.      notification of the receipt of the MNP attention message and
  481.      hence it is assumed that MNPBREAK will only be  employed when the
  482.      remote side of the connection is an MNP error-correcting
  483.      modem.]